Skip to content

simd(avx2): fix F64x8::reduce_min/max regression from #435 + before/after disassembly and Mandelbrot results - #436

Merged
AdaWorldAPI merged 1 commit into
masterfrom
claude/practical-newton-u8lir8
Nov 17, 2026
Merged

AdaWorldAPI merged 1 commit into
masterfrom
claude/practical-newton-u8lir8

Conversation

@AdaWorldAPI

@AdaWorldAPI AdaWorldAPI commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

One code fix, plus the measurements that found it.

Code (src/simd_avx2.rs, one method pair)

The AVX2 F64x8::reduce_min / reduce_max are back to master's body: an iterator fold over the fixed-size lane array, which is the shape simd_ops is built on.

PR #435 had replaced that body with a hand-written vminpd/vblendvpd tree. The before/after probe showed the tree was 1.9× slower: 2.15 → 4.03 ns per call, and 21 → 27 instructions. With this fix the method is back to about 2.0 ns and 21 instructions.

Results are bit-identical before the PR, after it, and after this fix. No AVX-512 code is touched.

Docs (.claude/knowledge/simd-crate-comparison-wide-pulp-2026-11-17.md §§ 6–8, blackboard)

§ 7: PR #435 before and after, per method (llvm-objdump plus timing)

  • AVX-512: all 30 probe symbols disassemble identically before and after.
  • AVX2: LLVM had already vectorized master's lane loops, so most of the rewrite is neutral.
    • Compares are 3 instructions longer, with timing inside the noise.
    • The f64 reductions regressed, which is what this PR fixes.
    • The real gains: U8x64::mask_blend is 10× faster, F32x16 compare + select 2.4×, and F32x16 reductions 1.6×.

§ 6 and § 8: Mandelbrot, wide vs pulp vs ndarray

  • AVX-512: the ndarray and wide8 inner loops are identical, instruction for instruction. The 9% gap first measured was in the benchmark arm: a saturating float-to-int cast done one lane at a time. With an exact 2^52 add and to_bits(), both existing facade methods, ndarray takes 149–154 ms against 152–157 ms for wide8 and 155–156 ms for pulp.
  • AVX2: ndarray stays behind. The compare result is packed into the public bitmask and expanded again for select.

Working rule recorded: write an operation as a fixed-size-array expression (as_chunks, the simd_ops helpers, the typed vectors' own methods) and read the disassembly first. Use intrinsics only where the compiler demonstrably did not vectorize.

Verification

  • Parity tests: tests/simd_lane_masks (including the NaN compatibility tests) and simd_float_classify pass on v3 and avx.
  • Lib tests: 2692 passed on v3.
  • masking-parity: passes on pinned v3 and on avx-qemu, with the IEEE digest unchanged.
  • Static checks: clippy -D warnings, fmt, the facet-stride guard and the ternlog generator check are all clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XAqKMQaYXab73XQdjqZfAW

Adds section 6 to the wide/pulp comparison: measured medians on x86-64-v4
and x86-64-v3 (1 and 4 threads), the pre-PR ndarray reference on v3, the
grading of P1-P4 (P3 failed: LLVM had already vectorized most of the old
scalar compare loop) and what the hot-loop disassembly shows about the
remaining gaps. Blackboard entry added. Docs only.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMQaYXab73XQdjqZfAW
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f84d4ca0-16bb-4832-bd77-dd4f5fe5d3f9
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review November 17, 2026 18:17
@AdaWorldAPI
AdaWorldAPI merged commit 76c6e8e into master Nov 17, 2026
20 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T18:19:11.880554Z fa35563 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@AdaWorldAPI AdaWorldAPI changed the title docs: Mandelbrot wide / pulp / ndarray results, predictions graded simd(avx2): fix F64x8::reduce_min/max regression from #435 + before/after disassembly and Mandelbrot results Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants